from pynput.mouse import Button, Controller
import time, os
import tkinter

# 获取鼠标对象
mouse = Controller()
root = tkinter.Tk()
try:
    while True:
        x, y = mouse.position
        print('鼠标坐标为{0}，{1}'.format(str(x), str(y)))
        time.sleep(0.2)
except KeyboardInterrupt:
    print("end......")
# # 输出鼠标当前的坐标
# print(mouse.position)
# # 将新的坐标赋值给鼠标对象
# mouse.position = (100, 500)
# print(mouse.position)
# for index in range(0, 30):
#     # 鼠标移动到指定坐标轴
#     mouse.move(index, -index)
#     print(mouse.position)
#     time.sleep(0.01)
# 鼠标右键按下
# mouse.press(Button.right)
#
# time.sleep(0.1)
#
# # 鼠标右键抬起
# mouse.release(Button.right)
# time.sleep(1)
# # 鼠标左键点击
# mouse.click(Button.left, 1)

# 鼠标滚轮滚动距离500
# mouse.scroll(0, 500)
